package com.itheima.pinda.file.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.itheima.pinda.file.dto.AttachmentDTO;
import com.itheima.pinda.file.dto.AttachmentRemoveDTO;
import com.itheima.pinda.file.dto.AttachmentResultDTO;
import com.itheima.pinda.file.dto.FilePageReqDTO;
import com.itheima.pinda.file.entity.Attachment;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 附件处理服务层
 *
 * @author:ivan.liu
 */
public interface AttachmentService extends IService<Attachment> {
    /**
     * 上传业务
     * @param file
     * @param bizId
     * @param bizType
     * @param isSingle
     * @param id
     * @return
     */
    AttachmentDTO upload(MultipartFile file, Long bizId, String bizType, Boolean isSingle, Long id);

    /**
     * 删除业务
     * @param ids
     * @return
     */
    void delete(Long[] ids);

    /**
     * 根据业务id或业务类型删除
     * @param dto
     */
    void deleteByBiz(AttachmentRemoveDTO dto);

    /**
     * 根据文件ids打包下载
     * @param ids
     */
    void download(HttpServletRequest request, HttpServletResponse response, Long[] ids)  throws Exception ;

    /**
     * 根据业务类型或业务id下载附件
     * @param bizIds
     * @param bizTypes
     * @param request
     * @param response
     * @throws Exception
     */
    void downloadByBiz(String[] bizIds, String[] bizTypes, HttpServletRequest request, HttpServletResponse response) throws Exception;

    /**
     * 查询附件分页数据
     *
     * @param page
     * @param data
     * @return
     */
    IPage<Attachment> page(Page<Attachment> page, FilePageReqDTO data);

    /**
     * 根据业务类型和业务id查询附件
     *
     * @param bizTypes
     * @param bizIds
     * @return
     */
    List<AttachmentResultDTO> find(String[] bizTypes, String[] bizIds);
}
